package com.wechat.back.mapper;

import com.wechat.back.pojo.comment.ArticleComment;
import com.wechat.back.pojo.comment.PoiComment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Insert("insert into article_comment(username, user_id, article_title, article_id, comment_content, like_count, status, create_time,update_time) " +
            "values (#{username},#{userId},#{articleTitle},#{articleId},#{commentContent},#{likeCount},#{statue},#{createTime},#{updateTime})")
    void addArticleComment(ArticleComment articleComment);

    @Insert("insert into poi_comment(username, user_id, poi_name, poi_id, comment_content, like_count, rating, status, create_time,update_time)" +
            " values (#{username},#{userId},#{poiName},#{poiId},#{commentContent},#{likeCount},#{rating},#{statue},#{createTime},#{updateTime})")
    void addPoiComment(PoiComment poiComment);

    List<ArticleComment> getArticleComment(String username,Integer commentId,Integer userId,Integer articleId);

    List<PoiComment> getPoiComment(String username, Integer commentId,Integer userId,Integer poiId);

    @Delete("delete from article_comment where comment_id=#{commentId}")
    void deleteArticleComment(Integer commentId);

    @Delete("delete from poi_comment where comment_id=#{commentId}")
    void deletePoiComment(Integer commentId);

    @Update("update article_comment set comment_content=#{commentContent},like_count=#{likeCount},status=#{statue},update_time=#{updateTime} where comment_id=#{commentId}")
    void updateArticleComment(ArticleComment articleComment);

    @Update("update poi_comment set comment_content=#{commentContent},like_count=#{likeCount},rating=#{rating},status=#{statue},update_time=#{updateTime} where comment_id=#{commentId}")
    void updatePoiComment(PoiComment poiComment);

    @Update("update article_comment set like_count=#{likeCount} where comment_id=#{commentId}")
    void updateArticleLikeCount(Integer likeCount, Integer commentId);

    @Update("update poi_comment set like_count=#{likeCount} where comment_id=#{commentId}")
    void updatePoiLikeCount(Integer likeCount, Integer commentId);
}
